﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using Follow.Utils;
using Follow.Model;
using System.Transactions;

namespace Follow.DataAccess
{
    public class AlertadoDAO
    {
        private SqlDataReader reader = null;
        private SqlConnection conn = null;
        private SqlCommand cmd = null;

        public AlertadoDAO()
        {
            conn = ConnectionUtils.getConnection();
        }

        public IList<Funcionario> findByFunc(Int32 id)
        {
            IList<Funcionario> listafunc = new List<Funcionario>();
            try
            {
                conn.Open();
                String sqlCommand = " select * from alertado where funcionario_idfuncionario = " + id;
                cmd = new SqlCommand(sqlCommand, conn);
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Funcionario f = new Funcionario();
                    f.IDFuncionario = reader.GetInt32(0);
                    listafunc.Add(f);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                if (conn != null)
                {
                    conn.Close();
                }
            }
            return listafunc;
        }
    }
}